import requests from '@/utils/request'
import type { LoginParams, userInfo } from '@/props/user'

export const userLogin = ({email,password}:LoginParams) =>{
  return requests.post("/feng/user/login",{
    email,
    password
  })
}

export const userRegister = (phoneNumber:string,password:string) => {
  return requests.post("/feng/user/register",{
    phoneNumber,
    password
  })
}

export const setUserInfo = ({name,avatarUrl,email,phoneNumber,createdAt}:userInfo) => {
  return requests.put("/feng/user/userInfoPC",{
    name,
    avatarUrl,
    email,
    phoneNumber,
    createdAt
  })
}


export const getUserInformation = (userId:number) => {
  return requests.get(`/feng/user/userInformation/${userId}`)
}


export const imgUpload = (file:FormData) => {
  return requests.post('/feng/file/upload',file,{
    headers:{
      'Content-Type': 'multipart/form-data', // 不需要手动设置，Axios 会自动处理
    }
  }
  )
}


export const setUserPassword = (password:string) => {
  return requests.put('/feng/user/setPassword',{
    password
  })
}
